<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="./index.js"></script>
</head>
<body>
  <style>
    .tab {
      width: 200px;
      height: 200px;
    }
    .tab dl dt {
      background-color: cyan;
    }
  </style>
  <div class="tab">
    <h3 id="h3" data-id="111">hello </h3>
    <dl>
      <dt data-action="toggle">在线教程</dt>
      <dd data-action="hidden">houdunren.com</dd>
    </dl>
    <dl>
      <dt data-action="toggle">开源软件</dt>
      <dd data-action="hidden">hdcms.com</dd>
    </dl>
  </div>
  <script>
    const h3 = document.querySelector('#h3')
    h3.addEventListener('copy', function(event){
      event.preventDefault()
      console.log('阻止了访问!');
    })
    let xhr
    if(window.XMLHttpRequest){
      xhr = new XMLHttpRequest()
    }else if(window.ActiveXObject) {
      xhr = new ActiveXObject()
    }
    xhr.open('get','http://baidu.com')
    xhr.send()
    xhr.onload = () =>{
      if(xhr.status === 200){
        console.log(xhr.reponseText);
      }
    }     
  class HD {
    constructor(el) {
      this.el = el
      el.addEventListener('click', this.handle.bind(this))
    }
    handle() {
      const action = event.target.dataset.action
      if (action) this[action]()
    }
    hidden() {
      event.target.hidden = true
    }
    toggle() {
      this.el.querySelectorAll(`[data-action='hidden']`).forEach((e) => (e.hidden = true))
      event.target.nextElementSibling.hidden = ''
    }
  }
  new HD(document.querySelector('.tab'))

  </script>
</body>
</html>